package com.letfox.test.example;

import java.math.BigDecimal;
import java.util.Date;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import com.letfox.common.util.UUIDHexGenerator;
import com.letfox.finance.dao.AccountDao;
import com.letfox.finance.dao.IncomeDetailDao;
import com.letfox.finance.enums.FINDelEnums;
import com.letfox.finance.enums.FINInWayEnums;
import com.letfox.finance.enums.FINInoutPayChannelEnums;
import com.letfox.finance.model.FINAccount;
import com.letfox.finance.model.FINIncomeDetail;
import com.letfox.test.util.MyBatisUtil;

public class IncomeDetailExample {

	private IncomeDetailDao incomeDetailDao;
	
	@Test
	public void addAccount(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		FINIncomeDetail finIncomeDetail = new FINIncomeDetail();
		finIncomeDetail.setFinIncomeId("40289a816289660f016289660f3b0000");
		finIncomeDetail.setFinAvailAmount(new BigDecimal("100"));
		finIncomeDetail.setFinInAmount(new BigDecimal("100"));
		finIncomeDetail.setFinInPayChannel(FINInoutPayChannelEnums.FINInoutPayChannel.WXPAY.getValue());
		finIncomeDetail.setFinInWay(FINInWayEnums.FINInWay.POINTS.getValue());
		finIncomeDetail.setCreateTime(new Date());
		finIncomeDetail.setFinInAccount("622202220101");
		finIncomeDetail.setCreateBy("admin");
		finIncomeDetail.setDel(FINDelEnums.UDMDel.EFFECTIVE.getValue());
		incomeDetailDao = session.getMapper(IncomeDetailDao.class);
		incomeDetailDao.insertSelective(finIncomeDetail);
	}
	
	@Test
	public void updateAccount(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		FINIncomeDetail finIncomeDetail = new FINIncomeDetail();
		finIncomeDetail.setDel(FINDelEnums.UDMDel.DELETE.getValue());
		incomeDetailDao = session.getMapper(IncomeDetailDao.class);
		incomeDetailDao.updateByPrimaryKeySelective(finIncomeDetail);
	}
	
	@Test
	public void selectAccount(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		
		String accoutId = "40289a816289660f016289660f3b0000";
		incomeDetailDao = session.getMapper(IncomeDetailDao.class);
		FINIncomeDetail finIncomeDetail = incomeDetailDao.selectByPrimaryKey(accoutId);
		System.out.println(finIncomeDetail.toString());
	}

}
